package com.example.demo.mapper;

import com.example.demo.pojo.Goodsaddguanli;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author yanglup
 * @create 2020-12-05 21:18
 */
@Mapper
public interface BooksMapper {
    /**查询添加的图书*/
    @Select("select * from goodsaddtable")
    List<Goodsaddguanli> Booklist();
    /**查询图书列表数*/
    @Select("select count(*) from goodsaddtable;")
    Integer Booklistnumber();

    /**添加图书*/
    @Insert("insert into goodsaddtable(cat_id,goods_name,goods_price,goods_number,school,goods_oldnew,goods_described,goods_small_logo,goods_small_logo2,goods_small_logo3,cat_one_id,cat_two_id,goods_serial,openid,status) " +
            "values (#{cat_id},#{goods_name},#{goods_price},#{goods_number},#{school},#{goods_oldnew},#{goods_described},#{goods_small_logo},#{goods_small_logo2},#{goods_small_logo3},#{cat_one_id},#{cat_two_id},#{goods_serial},#{openid},#{status});")
    void Bookaddtijiao(Integer cat_id, String goods_name, Integer goods_price, Integer goods_number, String school, String goods_oldnew, String goods_described,
                       String goods_small_logo, String goods_small_logo2, String goods_small_logo3, Integer cat_one_id, Integer cat_two_id, String goods_serial, String openid, Integer status);

    /**修改1*/
    @Select("select * from goodsaddtable where goods_id=#{goods_id};")
    Goodsaddguanli Bookupdate(Integer goods_id);
    /**修改2  更新*/
    @Update("update goodsaddtable set goods_id=#{goods_id},cat_id=#{cat_id},goods_name=#{goods_name},goods_price=#{goods_price},goods_number=#{goods_number},school=#{school}," +
            "goods_oldnew=#{goods_oldnew},goods_described=#{goods_described},goods_small_logo=#{goods_small_logo},goods_small_logo2=#{goods_small_logo2}," +
            "goods_small_logo3=#{goods_small_logo3},cat_one_id=#{cat_one_id},cat_two_id=#{cat_two_id},openid=#{openid},status=#{status} where goods_id=#{goods_idchuanru};")
    void Bookupdatetijiao(Integer goods_idchuanru, Integer goods_id, Integer cat_id, String goods_name, Integer goods_price, Integer goods_number, String school, String goods_oldnew, String goods_described,
                          String goods_small_logo, String goods_small_logo2, String goods_small_logo3, Integer cat_one_id, Integer cat_two_id, String openid, Integer status);


    /**删除图书*/
    @Delete("delete from goodsaddtable where goods_id=#{goods_id};")
    void Bookdelete(Integer goods_id);


    /**搜索图书*/
    @Select("select * from goodsaddtable where goods_name like CONCAT('%',#{goods_name},'%');")
    List<Goodsaddguanli> Booksearch(String goods_name);
    /**搜索图书的数量*/
    @Select("select count(*) from goodsaddtable where goods_name like CONCAT('%',#{goods_name},'%');")
    Integer Booksearchnumber(String goods_name);

}
